import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)
export default new Vuex.Store({//创建仓库
  state:{//公用数据
    city: localStorage.city ||"马泉营"
  },
  actions:{
    changeCity(ctx,city){
        ctx.commit('changeCity',city)//调用mutations改变公用变量
    }
  },
  mutations:{
    changeCity(state,city){
        state.city = city
        localStorage.city=city//本地存储
    }
  }
})
